<?php
namespace Tool\Controller;

use Think\Controller;

/**
 * Created by PhpStorm.
 * User: an
 * Date: 2015/9/8
 * Time: 8:54
 */
class TestMailController extends Controller{


    public function index(){
        $this->display();
    }

    /**
     * 注册
     */
    public function register(){
        include_once("smtp.class.php");
        $email=I('email','');
        $smtpserver = "smtp.163.com"; //SMTP服务器
        $smtpserverport = 25; //SMTP服务器端口
        $smtpusermail = "17826893160@163.com"; //SMTP服务器的用户邮箱
        $smtpuser = "17826893160@163.com"; //SMTP服务器的用户帐号
        $smtppass = "tokekmqgtljarzvp"; //SMTP服务器的用户密码
        $smtp = new \Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证.
        $emailtype = "HTML"; //信件类型，文本:text；网页：HTML
        $smtpemailto = $email;
        $smtpemailfrom = $smtpusermail;
        $emailsubject = "用户帐号激活";
        $emailbody = "亲爱的王玉国："."<br/>感谢您在我站注册了新帐号。<br/>请点击链接激活您的帐号。<br/><a href='http://www.baidu.com'>点我</a><br/>如果发送成功。<br/>请忽略本邮件。<br/><p style='text-align:right'>-------- www.itboye.com 敬上</p>";
        $rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype);
        if($rs==1){
            //$msg = '恭喜您，注册成功！<br/>请登录到您的邮箱及时激活您的帐号！';
            dump("发送成功！");
        }else{
            $msg = $rs;
            dump("发送失败！");
        }
    }

}